package com.lingyue.commons.response;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author deep.wu
 * @version 1.0 on 2019/12/2 16:18.
 */
public class ResWriter {

    /**
     * 输出json数据字符串
     *
     * @param response
     *            HttpServletResponse对象
     * @param jsonDataStr
     *            json字符串
     */
    public static void outJson(HttpServletResponse response, Object jsonDataStr) {
        try {
            response.setContentType("application/json;charset=utf-8");
            PrintWriter out = response.getWriter();
            out.print(jsonDataStr);
            out.flush();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
